package ch2linkedlist;

public class ListNode {
	public ListNode next = null;
	public int val;

	public ListNode(int d) {
		val = d;
	}

	void appendToTail(int d) {
		ListNode end = new ListNode(d);
		ListNode n = this;
		while (n.next != null) {
			n = n.next;
		}
		n.next = end;
	}

	@Override
	public String toString() {
		return Integer.toString(val);
	}

	public void setNext(ListNode next) {
		this.next = next;
	}
	
//	@Override
//	public int hashCode() {
//		return data;
//	}
}